﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ymatou.ServiceCenter.Common
{
    public sealed class CheckArgument
    {
        public static void NotNull(object value, string parameterName)
        {
            if (value == null)
                throw new ArgumentNullException(parameterName);
        }

        public static void NotEmpty(string value, string parameterName)
        {
            if (value == null || value.Length != 0) return;
            throw new ArgumentException(string.Format("参数['{0}']不能为空", parameterName));
        }

        public static void NotNullOrEmpty(string value, string parameterName)
        {
            if (string.IsNullOrEmpty(value))
                throw new ArgumentException(string.Format("参数['{0}']不能为空", parameterName));
        }

        public static void NotNullOrWhiteSpace(string value, string parameterName)
        {
            if (string.IsNullOrWhiteSpace(value))
                throw new ArgumentException(string.Format("参数['{0}']不能为空", parameterName));
        }
    }
}
